<?php


namespace backend\modules\tool\models;


use backend\modules\tool\helpers\functions;
use yii\base\Model;

class AutoSearchModle extends Model
{
    /**
     * @var Model $attrbute_model
     */
    public $formname=null;
    public $attrbute_model;
    public function load($data, $formName = null)
    {
//        if(!empty($formName)) {
//            $data = $data['AutoSearchModle'] ?? [];
//        }
        if(!empty($data['AutoSearchModle'])){
            $data = $data['AutoSearchModle'] ?? [];
        }
        if(empty($data)){
            $data=[];
        }
        foreach ($data as $key=>$value){
            $this->$key=$value;
        }
//        print_r($data);
//        die();
        return parent::load($data, $formName); // TODO: Change the autogenerated stub
    }
    public function __set($name, $value)
    {
        $this->$name=$value;
    }
    public function attributes()
    {
        return parent::attributes(); // TODO: Change the autogenerated stub
    }

    public function toArray(array $fields = [], array $expand = [], $recursive = true)
    {
        return get_object_vars($this);
    }
    public function __get($name)
    {
        return null;
        return parent::__get($name); // TODO: Change the autogenerated stub
    }
    public static function GetObject($class_name)
    {
        $object=new self();
//        echo $class_name;die();
        $object->load(functions::HttpParamsAll(),$class_name);
        $object->attrbute_model=new $class_name();
        return $object;
    }
    public function attributeLabels()
    {
        return $this->attrbute_model->attributeLabels();
    }
}